package vip.zhenzicheng.rocketmq.rocketmq;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消费者
 *
 * @author zhenzicheng
 * @date 2022-05-28 19:33
 */
@Component
// 使用多线程并发消费
@RocketMQMessageListener(consumerGroup = "${rocketmq.consumer.group}", topic = "TestTopic", consumeMode =
  ConsumeMode.CONCURRENTLY)
@Slf4j
public class SpringConsumer implements RocketMQListener<String> {

  @Override
  public void onMessage(String message) {
    log.info("接收消息: {}", message);
  }
}
